package com.yanqu.road.server.cmd.house;

import com.yanqu.road.pb.house.HouseProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.HouseModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_HOUSE_TOAD_GET_REWARD, desc = "钱庄领取金蟾奖励")
public class HouseToadGetRewardCmd extends AbstractCommand {

	private long silver;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		HouseProto.HouseToadGetRewardReqMsg reqMsg = HouseProto.HouseToadGetRewardReqMsg.parseFrom(packet.getBytes());
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		silver = player.getModule(HouseModule.class).getToadReward();
		player.getModule(HouseModule.class).syncUserHouseBank();
	}

	@Override
	public void sendData(GamePlayer player) {
		HouseProto.HouseToadGetRewardRespMsg.Builder respMsg = HouseProto.HouseToadGetRewardRespMsg.newBuilder();
		respMsg.setRet(ret);
		respMsg.setSilver(silver);
		player.sendPacket(Protocol.U_HOUSE_TOAD_GET_REWARD, respMsg);
	}
}
